function request(url, data = {}, type = 'get') {
  return new Promise(resolve => {
    $.ajax({
      url,
      data,
      type,
      dataType: 'json',
      success: data => {
        resolve(data);
      }
    })
  })
}

const baseUrl = location.href.indexOf('zk123.gz01.bdysite.com')=== -1 ? 'http://localhost':'zk123.gz01.bdysite.com';

export const APILogin = data => request(`${baseUrl}/php/02login.php`, data);
export const APIRegister = data => request(`${baseUrl}/php/01register.php`, data);
export const APIGoodsList = data => request(`${baseUrl}/php/06goods-list.php`, data);
export const APIGoodsDetail = data => request(`${baseUrl}/php/07good-detail.php`, data);
export const APIAddCart = data => request(`${baseUrl}/php/08cart-add.php`, data);
export const APICartList = data => request(`${baseUrl}/php/09cart-list.php`, data);
export const APICartUpdate = data => request(`${baseUrl}/php/10cart-update.php`, data);
export const APICartDelete = data => request(`${baseUrl}/php/11cart-delete.php`,data);


